import Sequelize from 'sequelize'
import electron from 'electron'

const { remote } = electron
const app = electron.app || remote.app

// 写入用户目录
const configDir = app.getPath('userData')
const fileName = 'database.sqlite'
const SYS_PATH = `${configDir}/${fileName}`

// 初始化本地数据库
export default {
  init () {
    return new Sequelize({
      dialect: 'sqlite',
      storage: SYS_PATH,
      logging (sqlLog) {
        console.log(sqlLog)
      }
    })
  }
}
